package com.admin.action.book_type_action;

import com.admin.Action;
import  com.pojo.BookTypeBean;
import com.admin.service.booktypeservice.BookTypeService;
import com.admin.service.booktypeservice.BookTypeServiceInF;
import com.pojo.BookTypeBean;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;


public class BookTypeAddAction extends Action {

    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
//        String type = request.getParameter("type");
        String name = request.getParameter("typename");
        String address = request.getParameter("address");
        PrintWriter out=response.getWriter();
        //天啊及
        HttpSession session = request.getSession();
//        System.out.println(session.getAttribute("adminInfo"));
        if(session.getAttribute("adminInfo")==null){
            out.println("<script>parent.window.location.href='error.html';</script>");
            return;
        }


        System.out.println(name+""+address);


        BookTypeBean bookTypeBean=new BookTypeBean();
        bookTypeBean.setTypeAddress(name);
        bookTypeBean.setTypeName(address);
        BookTypeServiceInF bo=new BookTypeService();
//        bo.insertBookType(bookTypeBean);
        if(bo.insertBookType(bookTypeBean)){
           out.print("成功");
        }else {
            out.print("失败");
        }


    }
}
